home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 1995 #5 & #6
/
Amiga Plus CD - 1995 - No. 5 and 6.iso
/
pd
/
serien
/
purity
/
nr.51
/
xpk-kp
/
unit_xpk.p
< prev
next >
Wrap
Text File
|
1995-08-27
|
13KB
|
365 lines
{ Unit: Xpk
~~~~~
Version: V0.02 / 10.11.1994
~~~~~~~~
What is it: Xpk.Library-Interface for KickPascal/MaxonPascal
~~~~~~~~~~~
Copyright: The interface is © & (P) 1994 by Janosh/NPL (J.Stötzer)
~~~~~~~~~~ It's free 4 use and distribution.
Xpk is © 1991 by C. Schneider & U.D. Mueller
Contact: J. Stötzer
~~~~~~~~ An der Hasel 195
D-98527 Suhl
Germany
Comment: For sublibrary handling you'll need Unit XpkSub, which
~~~~~~~~ belongs to this package.
}
{*************************************************************************}
Unit Xpk;
{$opt q}
INTERFACE
Uses Exec;
{$incl "utility/tagitem.h","utility/hooks.h"}
const XPKNAME = 'xpkmaster.library';
{******************************************************************************
*
* The packing/unpacking tags
*
*}
const XPK_TagBase = (TAG_USER+(ord('X')*256)+ord('P'));
{Caller must supply ONE of these to tell XpkPackFile where to get data from}
XPK_InName = (XPK_TagBase+$01); {Name of a single data file}
XPK_InFH = (XPK_TagBase+$02); {File handle - read from current position}
XPK_InBuf = (XPK_TagBase+$03); {Unblocked buffer - must also supply InLen}
XPK_InHook = (XPK_TagBase+$04); {Callback Hook to get input data}
{Caller must supply ONE of these to tell XpkPackFile where to send data to}
XPK_OutName = (XPK_TagBase+$10); {Write (or overwrite) this data file}
XPK_OutFH = (XPK_TagBase+$11); {File handle - write from current position on}
XPK_OutBuf = (XPK_TagBase+$12); {Unblocked buffer - must also supply OutBufLen}
XPK_GetOutBuf = (XPK_TagBase+$13);{Master allocates OutBuf - ti_Data points to buffer pointer}
XPK_OutHook = (XPK_TagBase+$14); {Callback Hook to get output buffers}
{Other junk}
XPK_InLen = (XPK_TagBase+$20); {len of data in input buffer}
XPK_OutBufLen = (XPK_TagBase+$21); {len of output buffer}
XPK_GetOutLen = (XPK_TagBase+$22); {ti_Data points to long to receive OutLen}
XPK_GetOutBufLen = (XPK_TagBase+$23); {ti_Data points to long to receive OutBufLen}
XPK_Password = (XPK_TagBase+$24); {password for de/encoding}
XPK_GetError = (XPK_TagBase+$25); {ti_Data points to buffer for error message}
XPK_OutMemType = (XPK_TagBase+$26); {Memory type for output buffer}
XPK_PassThru = (XPK_TagBase+$27); {Bool: Pass through unrecognized formats}
XPK_StepDown = (XPK_TagBase+$28); {Bool: Step down pack method if necessary}
XPK_ChunkHook = (XPK_TagBase+$29); {Call this Hook between chunks}
XPK_PackMethod = (XPK_TagBase+$2a); {Do a FindMethod before packing}
XPK_ChunkSize = (XPK_TagBase+$2b); {Chunk size to try to pack with}
XPK_PackMode = (XPK_TagBase+$2c); {Packing mode for sublib to use}
XPK_NoClobber = (XPK_TagBase+$2d); {Don't overwrite existing files }
XPK_Ignore = (XPK_TagBase+$2e); {Skip this tag }
XPK_TaskPri = (XPK_TagBase+$2f); {Change priority for (un)packing}
XPK_FileName = (XPK_TagBase+$30); {File name in progress report}
XPK_ShortError = (XPK_TagBase+$31); {Output short error messages }
XPK_PackersQuery = (XPK_TagBase+$32); {Query available packers }
XPK_PackerQuery = (XPK_TagBase+$33); {Query properties of a packer }
XPK_ModeQuery = (XPK_TagBase+$34); {Query properties of packmode }
XPK_LossyOK = (XPK_TagBase+$35); {Lossy packing permitted? def.=no}
XPK_FindMethod = XPK_PackMethod;
XPK_MARGIN = 256;
{**************************************************************************
*
* Message passed to InHook and OutHook
*
*}
type p_XpkIOMsg = ^XpkIOMsg;
XpkIOMsg = record
xiom_Type : long; {Read/Write/Alloc/Free/Abort}
xiom_Ptr : ptr; {The mem area to read from/write to}
xiom_Size : long; {The size of the read/write }
xiom_IOError : long; {The IoErr() that occurred }
xiom_Reserved : long; {Reserved for future use }
xiom_Private1 : long; {Hook specific, will be set to 0 by}
xiom_Private2 : long; {master library before first use}
xiom_Private3 : long;
xiom_Private4 : long;
end;
{The values for XpkIoMsg->Type}
const
XIO_READ = 1;
XIO_WRITE = 2;
XIO_FREE = 3;
XIO_ABORT = 4;
XIO_GETBUF = 5;
XIO_SEEK = 6;
XIO_TOTSIZE = 7;
{******************************************************************************
*
*
* The progress report interface
*
*}
type p_XpkProgress = ^XpkProgress;
XpkProgress = record
xp_Type : long; {Type of report: start/cont/end/abort}
xp_PackerName : str; {Brief name of packer being used }
xp_PackerLongName : str; {Descriptive name of packer being used }
xp_Activity : ptr; {Packing/unpacking message }
xp_FileName : str; {Name of file being processed, if available}
xp_CCur : long; {Amount of packed data already processed}
xp_UCur : long; {Amount of unpacked data already processed }
xp_ULen : long; {Amount of unpacked data in file }
xp_CF : long; {Compression factor so far }
xp_Done : long; {Percentage done already }
xp_Speed : long; {Bytes per second, from beginning of stream}
xp_Reserved : array[0..7] of long; {For future use }
end;
const
XPKPROG_START = 1;
XPKPROG_MID = 2;
XPKPROG_END = 3;
{*****************************************************************************
*
*
* The file info block
*
*}
type p_XpkFib = ^XpkFib;
XpkFib = record
xf_Type : long; {Unpacked, packed, archive? }
xf_ULen : long; {Uncompressed length }
xf_CLen : long; {Compressed length }
xf_NLen : long; {Next chunk len }
xf_UCur : long; {Uncompressed bytes so far }
xf_CCur : long ; {Compressed bytes so far }
xf_ID : long; {4 letter ID of packer }
xf_Packer : array[0..5] of byte; {4 letter name of packer }
xf_SubVersion : word; {Required sublib version }
xf_MasVersion :word; {Required masterlib version }
xf_Flags : long; {Password? }
xf_Head : array[0..15] of byte; {First 16 bytes of orig. file}
xf_Ratio : long; {Compression ratio }
xf_Reserved : array[0..7] of long; {For future use }
end;
const
XPKTYPE_UNPACKED = 0; {Not packed }
XPKTYPE_PACKED = 1; {Packed file }
XPKTYPE_ARCHIVE = 2; {Archive }
XPKFLAGS_PASSWORD = 1; {Password needed }
XPKFLAGS_SEEK = 2; {Chunks are independent }
XPKFLAGS_NONSTD = 4; {Nonstandard file format }
type p_XpkFH = ^XpkFH;
XpkFH = record
fib : XpkFib;
{Sum more private and not documented data...}
end;
{******************************************************************************
*
* The error messages
*
*}
const
XPKERR_OK = 0;
XPKERR_NOFUNC = -1; {This function not implemented }
XPKERR_NOFILES = -2; {No files allowed for this function }
XPKERR_IOERRIN = -3; {Input error happened, look at Result2}
XPKERR_IOERROUT = -4; {Output error happened, look at Result2}
XPKERR_CHECKSUM = -5; {Check sum test failed }
XPKERR_VERSION = -6; {Packed file's version newer than lib's}
XPKERR_NOMEM = -7; {Out of memory }
XPKERR_LIBINUSE = -8; {For not-reentrant libraries }
XPKERR_WRONGFORM = -9; {Was not packed with this library }
XPKERR_SMALLBUF = -10; {Output buffer too small }
XPKERR_LARGEBUF = -11; {Input buffer too large }
XPKERR_WRONGMODE = -12; {This packing mode not supported }
XPKERR_NEEDPASSWD = -13; {Password needed for decoding this file}
XPKERR_CORRUPTPKD = -14; {Packed file is corrupt }
XPKERR_MISSINGLIB = -15; {Required library is missing }
XPKERR_BADPARAMS = -16; {Caller's TagList was screwed up }
XPKERR_EXPANSION = -17; {Would have caused data expansion }
XPKERR_NOMETHOD = -18; {Can't find requested method }
XPKERR_ABORTED = -19; {Operation aborted by user }
XPKERR_TRUNCATED = -20; {Input file is truncated }
XPKERR_WRONGCPU = -21; {Better CPU required for this library}
XPKERR_PACKED = -22; {Data are already XPacked }
XPKERR_NOTPACKED = -23; {Data not packed }
XPKERR_FILEEXISTS = -24; {File already exists }
XPKERR_OLDMASTLIB = -25; {Master library too old }
XPKERR_OLDSUBLIB = -26; {Sub library too old }
XPKERR_NOCRYPT = -27; {Cannot encrypt }
XPKERR_NOINFO = -28; {Can't get info on that packer }
XPKERR_LOSSY = -29; {This compression method is lossy }
XPKERR_NOHARDWARE = -30; {Compression hardware required }
XPKERR_BADHARDWARE = -31; {Compression hardware failed }
XPKERR_WRONGPW = -32; {Password was wrong }
XPKERRMSGSIZE = 80; {Maximum size of an error message }
{*****************************************************************************
*
*
* The XpkQuery() call
*
*}
type p_XpkPackerInfo = ^XpkPackerInfo;
XpkPackerInfo = record
xpi_Name : array[0..23] of char; {Brief name of the packer }
xpi_LongName : array[0..31] of char; {Full name of the packer }
xpi_Description : array[0..79] of char; {One line description of packer }
xpi_Flags : long; {Defined below }
xpi_MaxChunk : long; {Max input chunk size for packing }
xpi_DefChunk : long; {Default packing chunk size }
xpi_DefMode : word; {Default mode on 0..100 scale }
end;
const
XPKIF_PK_CHUNK = $00000001; {Library supplies chunk packing }
XPKIF_PK_STREAM = $00000002; {Library supplies stream packing }
XPKIF_PK_ARCHIVE = $00000004; {Library supplies archive packing }
XPKIF_UP_CHUNK = $00000008; {Library supplies chunk unpacking }
XPKIF_UP_STREAM = $00000010; {Library supplies stream unpacking }
XPKIF_UP_ARCHIVE = $00000020; {Library supplies archive unpacking }
XPKIF_HOOKIO = $00000080; {Uses full Hook I/O }
XPKIF_CHECKING = $00000400; {Does its own data checking }
XPKIF_PREREADHDR = $00000800; {Unpacker pre-reads the next chunkhdr}
XPKIF_ENCRYPTION = $00002000; {Sub library supports encryption }
XPKIF_NEEDPASSWD = $00004000; {Sub library requires encryption }
XPKIF_MODES = $00008000; {Sub library has different modes }
XPKIF_LOSSY = $00010000; {Sub library does lossy compression }
type p_XpkMode = ^XpkMode;
XpkMode = record
xm_Next : p_XpkMode; {Chain to next descriptor for ModeDesc list}
xm_Upto : long; {Maximum efficiency handled by this mode }
xm_Flags : long; {Defined below }
xm_PackMemory : long; {Extra memory required during packing }
xm_UnpackMemory : long; {Extra memory during unpacking }
xm_PackSpeed : long; {Approx packing speed in K per second }
xm_UnpackSpeed : long; {Approx unpacking speed in K per second }
xm_Ratio : word; {CF in 0.1% for AmigaVision executable }
xm_ChunkSize : word; {Desired chunk size in K (!!) for this mode}
xm_Description : array[0..9] of char; {8 character mode description}
end;
const
XPKMF_A3000SPEED = $00000001; {Timings on A3000/25 }
XPKMF_PK_NOCPU = $00000002; {Packing not heavily CPU dependent}
XPKMF_UP_NOCPU = $00000004; {Unpacking... (i.e. hardware modes)}
MAXPACKERS = 100;
type p_XpkPackerList = ^XpkPackerList;
XpkPackerList = record
xpl_NumPackers : long;
xpl_Packer : array[1..MAXPACKERS*6] of byte;
end;
{*****************************************************************************
*
*
* The XpkOpen() type calls
*}
const
XPKLEN_ONECHUNK = $7fffffff;
var XpkMasterBase : ptr;
Library XpkMasterBase:
{-30 : XpkPackerInfo; do not use}
-36 : function XpkExamine(a0:p_XpkFib;a1:p_TagItem):long;
-42 : function XpkPack(a0:p_TagItem):long;
-48 : function XpkUnpack(a0:p_TagItem):long;
-54 : function XpkOpen(a0:ptr;a1:p_TagItem):long; {a0=xFH**}
-60 : function XpkRead(a0:p_XpkFH;a1:ptr;d0:long):long; {a0=xFH*}
-66 : function XpkWrite(a0:ptr;a1:ptr;d0:long):long;
-72 : function XpkSeek(a0:ptr;d0,d1:long):long;
-78 : function XpkClose(a0:ptr):long;
-84 : function XpkQuery(a0:p_TagItem):long;
end;
function XTag(n:long):long;
function Xpk_Open(fh:p_XpkFH;ti:p_TagItem):long;
IMPLEMENTATION
function XTag;
begin
XTag:=XPK_TagBase+n;
end;
function Xpk_Open;
var pfh : ptr;
begin
pfh:=^fh;
Xpk_Open:=XpkOpen(pfh,ti);
end;
end.